class Solution {
public:
    int finalPositionOfSnake(int n, vector<string>& commands) {
        // 不考虑越界问题
        int pos = 0;
        for (auto& e : commands) {
            if (e == "UP") {
                pos -= n;
            } else if (e == "RIGHT") {
                pos++;
            } else if (e == "DOWN") {
                pos += n;
            } else if (e == "LEFT") {
                pos--;
            }
        }
        return pos;
    }
};